home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / u_man / cat1 / cflow.z / cflow
Encoding:
Text File  |  1998-10-30  |  18.2 KB  |  396 lines

  1.  
  2.  
  3.  
  4. CCCCFFFFLLLLOOOOWWWW((((1111))))                       SSSSiiiilllliiiiccccoooonnnn GGGGrrrraaaapppphhhhiiiiccccssss                       CCCCFFFFLLLLOOOOWWWW((((1111))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      cflow - generate C flowgraph
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      ccccfffflllloooowwww [----rrrr] [----iiiixxxx] [----iiii____ ] [----ddddnum] files
  13.  
  14. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  15.      The _c_f_l_o_w command analyzes a collection of C, yacc, and lex files and
  16.      attempts to build a graph charting the external references.  Files
  17.      suffixed with ....yyyy, ....llll, ....cccc, or ....iiii are yacced, lexed, and compiled as
  18.      appropriate.  The results are collected and turned into a graph which is
  19.      displayed upon the standard output.
  20.  
  21.      If the environment variable _XPG is defined, _c_f_l_o_w operates in
  22.      conformance with the X/Open XPG4 specifications.  The format of the
  23.      output may differ in accordance to the XPG4 standards.
  24.  
  25.      In addition to the ----DDDD, ----IIII, and ----UUUU options [which are interpreted just as
  26.      they are by _c_c(1) and _c_p_p(1)], the following options are interpreted by
  27.      _c_f_l_o_w:
  28.  
  29.      ----rrrr     Reverse the ``caller:callee'' relationship producing an inverted
  30.             listing showing the callers of each function.  The listing is
  31.             sorted in lexicographical order by callee.
  32.  
  33.      ----iiiixxxx    Include external and static data symbols. The default is to
  34.             include only functions in the flowgraph.  If _XPG is set, then
  35.             there could be 0 or more spaces between -i and x.
  36.  
  37.      ----iiii____    Include names that begin with an underscore. The default is to
  38.             exclude these functions (and data if -_i_x is used).  If _XPG is
  39.             set, then there could be 0 or more spaces between -i and _.
  40.  
  41.      ----ddddnum  The _n_u_m decimal integer indicates the depth at which the flowgraph
  42.             is cut off.  By default this is a very large number.  Attempts to
  43.             set the cutoff depth to a nonpositive integer are ignored.  If
  44.             _XPG is set, then there could be 0 or more spaces between -d and
  45.             num.
  46.  
  47.      ----ssssuuuupppppppprrrreeeessssssss suppressfile
  48.             Eliminates reporting of functions named in the file _s_u_p_p_r_e_s_s_f_i_l_e.
  49.             The format of the file is discussed below.
  50.  
  51.      ----nnnnaaaarrrrrrrroooowwww
  52.             The output is narrowed by removing the function type output,
  53.             changing all filenames to show only the filename (no directory
  54.             path) and by changing indentation to be two spaces (indentation is
  55.             not changed for ----rrrr ).
  56.  
  57.      ----bbbbaaaasssseeee basefunction
  58.             The flow reported starts at the function _b_a_s_e_f_u_n_c_t_i_o_n and only
  59.             reports descendents of that function.  (This option ignored for ----rrrr
  60.  
  61.  
  62.  
  63. Page 1                           Release 6.4
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. CCCCFFFFLLLLOOOOWWWW((((1111))))                       SSSSiiiilllliiiiccccoooonnnn GGGGrrrraaaapppphhhhiiiiccccssss                       CCCCFFFFLLLLOOOOWWWW((((1111))))
  71.  
  72.  
  73.  
  74.             )
  75.  
  76.      ----rrrraaaawwww   Instead of being processed into a cflow output, the raw cflow
  77.             information from the C compiler is passed directly to the output.
  78.             The format of this data is described below.
  79.  
  80.      ----rrrraaaawwwwiiiinnnn    _f_i_l_e
  81.             Pass in to _c_f_l_o_w for formatting the _f_i_l_e as if it were the output
  82.             of cflow -raw.  The file must be in the proper format: if it is
  83.             not, the result will likely be chaos.
  84.  
  85.      ----vvvv     Print on standard error the arguments passed to sub-passes and
  86.             such other information as seems interesting.
  87.  
  88. GGGGRRRRAAAAPPPPHHHH FFFFOOOORRRRMMMMAAAATTTT
  89.      Each line of output begins with a reference number, followed by a
  90.      suitable number of tabs indicating the level, then the name of the global
  91.      symbol followed by a colon and its definition.  Normally only function
  92.      names that do not begin with an underscore are listed (see the ----iiii options
  93.      below).  For information extracted from C source, the definition consists
  94.      of an abstract type declaration (e.g., cccchhhhaaaarrrr ****), and, delimited by angle
  95.      brackets, the name of the source file and the line number where the
  96.      definition was found.  Definitions extracted from object files indicate
  97.      type information (if possible), followed by the name of the file in which
  98.      the symbol appeared enclosed in angle brackets.  Leading underscores in
  99.      C-style external names are deleted.
  100.  
  101.      Once a definition of a name has been printed, subsequent references to
  102.      that name contain only the reference number of the line where the
  103.      definition may be found.  For undefined references, only <<<<>>>> is printed.
  104.  
  105.      As an example, given the following in _f_i_l_e._c:
  106.  
  107.        int     i;
  108.        static int localstat;
  109.  
  110.        int       main(int argc, char **argv)
  111.        {
  112.          f();
  113.          g(argc,argv);
  114.          f();
  115.          return(0);
  116.        }
  117.  
  118.        int  f()
  119.        {
  120.          i = h();
  121.          localstat = j();
  122.          return 0;
  123.        }
  124.  
  125.  
  126.  
  127.  
  128.  
  129. Page 2                           Release 6.4
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. CCCCFFFFLLLLOOOOWWWW((((1111))))                       SSSSiiiilllliiiiccccoooonnnn GGGGrrrraaaapppphhhhiiiiccccssss                       CCCCFFFFLLLLOOOOWWWW((((1111))))
  137.  
  138.  
  139.  
  140.      the command
  141.  
  142.              cflow -ix file.c
  143.  
  144.      produces the output
  145.  
  146.        1       main: int (int , char *(*)), <file.c 4>
  147.        2               g: int (), <file.c 7>
  148.        3               f: int (), <file.c 12>
  149.        4                       i: int, <file.c 1>
  150.        5                       h: int (), <file.c 14>
  151.        6                       localstat<file.c,0>: int, <file.c 2>
  152.        7                       j: int (), <file.c 15>
  153.  
  154.      When the nesting level becomes too deep, the output of _c_f_l_o_w can be piped
  155.      to _p_r(1), using the ----eeee option, to compress the tab expansion to something
  156.      less than every eight spaces.
  157.  
  158.      To keep file-local static variables and  functions  from  being  confused
  159.      from  variables  and functions in other files, statics are shown with the
  160.      compilation  unit  name   and   a   unique   number.    In   the   above,
  161.      _l_o_c_a_l_s_t_a_t<_f_i_l_e._c,_0> is an example of this convention.
  162.  
  163.      To be clear about functions  or variables defined inside  functions,  the
  164.      file  and  line  of  the  actual  definition is mentioned and, if it is a
  165.      #include-ed file, the name of the compilation-unit file is  mentioned  in
  166.      parentheses.  Example:
  167.             <stati1.h (in stati1.c) 2>
  168.  
  169.      Static variables defined inside a function and  function-local  variables
  170.      and parameters are never mentioned in the _c_f_l_o_w output.
  171.  
  172.      When analyzing the structure of a program,  focusing  on  what  a  single
  173.      function  does (_m_y_f_u_n_c for example) is sometimes helpful.  In such a case
  174.      a command like
  175.  
  176.                  cflow -narrow -base myfunc -suppress libcstuff file.c
  177.  
  178.      may be useful.  This reports only on _m_y_f_u_n_c, it keeps the  output  narrow
  179.      to  avoid  line-wrapping,  and if libc.so functions are named in the file
  180.      _l_i_b_c_s_t_u_f_f those (presumably well known and  therefore  uninteresting  for
  181.      your analysis) will not be shown.
  182.  
  183. DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
  184.      Most diagnostic messages come from the C compiler.  The C compiler is not
  185.      the same as _c_c.
  186.  
  187.      Diagnostics may also come from _y_a_c_cor _l_e_x, and generally appear on
  188.      standard error.
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195. Page 3                           Release 6.4
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. CCCCFFFFLLLLOOOOWWWW((((1111))))                       SSSSiiiilllliiiiccccoooonnnn GGGGrrrraaaapppphhhhiiiiccccssss                       CCCCFFFFLLLLOOOOWWWW((((1111))))
  203.  
  204.  
  205.  
  206.      The following come from _c_f_l_o_w:
  207.  
  208.      SSSSttttaaaattttiiiicccc yyyy ddddeeeeffffiiiinnnneeeedddd iiiinnnn <<<<ssssttttaaaattttiiii1111....hhhh ((((iiiinnnn ssssttttaaaattttiiii1111....cccc)))) 2222>>>> <<<<ssssttttaaaattttiiii1111....hhhh ((((iiiinnnn ssssttttaaaattttiiii2222....cccc)))) 2222>>>>
  209.      <<<<ssssttttaaaattttiiii1111....hhhh ((((iiiinnnn ssssttttaaaattttiiii3333....cccc)))) 2222>>>> means that the variable _y is defined as static
  210.      in the listed files at the listed line numbers.  The parenthesized name
  211.      is the source file being compiled:  whenever the source file of the
  212.      message is a #include-ed file _c_f_l_o_w shows the name of both the the
  213.      included file and the file name presented to the C compiler front-end.
  214.  
  215.      ccccfffflllloooowwww WWWWaaaarrrrnnnniiiinnnngggg:::: RRRReeeeddddeeeeffffiiiinnnniiiittttiiiioooonnnnssss ooooffff aaaannnnooootttthhhheeeerrrrzzzzeeeedddd :::: <<<<sssstttt2222....cccc 2222>>>> <<<<sssstttt3333....cccc 3333>>>> means
  216.      that the variable _a_n_o_t_h_e_r_z_e_d is defined in the listed source files at the
  217.      specified line numbers.
  218.  
  219.      ccccfffflllloooowwww WWWWaaaarrrrnnnniiiinnnngggg:::: EEEExxxxtttteeeerrrrnnnnaaaallll zzzzeeeedddd <<<<sssstttt2222....cccc 1111>>>> iiiissss ssssttttaaaattttiiiicccc iiiinnnn <<<<sssstttt1111....cccc 1111>>>> means that
  220.      the external variable _z_e_d is static in the listed file(s), which is a
  221.      little unusual.
  222.  
  223.      ccccfffflllloooowwww WWWWaaaarrrrnnnniiiinnnngggg:::: DDDDeeeeccccllllaaaarrrraaaattttiiiioooonnnn ttttyyyyppppeeee mmmmiiiissssmmmmaaaattttcccchhhh xxxx:::: means that the variable _x is
  224.      declared with different types in different source files.  The types and
  225.      declaration locations are shown in the message.
  226.  
  227. SSSSUUUUPPPPPPPPRRRREEEESSSSSSSS OOOOPPPPTTTTIIIIOOOONNNN FFFFIIIILLLLEEEE FFFFOOOORRRRMMMMAAAATTTT
  228.      Any line beginning with whitespace (blank, tab, or newline) is considered
  229.      a comment and all characters in the line (up through the next newline)
  230.      are ignored.
  231.  
  232.      If a line begins with other than whitespace, all characters up to the
  233.      first whitespace character are considered part of a name-to-be-
  234.      suppressed.  (Any characters on the line beginning at the first
  235.      whitespace character are considered comment and (up through the next
  236.      newline) are ignored.)
  237.  
  238.      The file of names to be ignored can contain as many names as desired. A
  239.      file containing zero lines or zero names-to-be-suppressed is also
  240.      allowed.
  241.  
  242.      Now we turn to a description of the processing of any name-to-be-
  243.      suppressed that may have been found by the above character scanning.
  244.  
  245.      Each name to be suppressed is processed by _r_e_g_c_m_p(3G) and _r_e_g_e_x(3G) and
  246.      _c_f_l_o_w supplies a leading "^" and a trailing "$".  See the _r_e_g_e_x(3G) man
  247.      page for further information about the available matching capabilities.
  248.  
  249.      For example, to match strlen, one could use  (strings are left justified
  250.      in the file but indented here so they stand out):
  251.           strlen
  252.  
  253.      To match all functions beginning with str, one could use
  254.           str.*
  255.      To match all functions with zzyzz in the name, one could use
  256.           .*zzyzz.*
  257.  
  258.  
  259.  
  260.  
  261. Page 4                           Release 6.4
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. CCCCFFFFLLLLOOOOWWWW((((1111))))                       SSSSiiiilllliiiiccccoooonnnn GGGGrrrraaaapppphhhhiiiiccccssss                       CCCCFFFFLLLLOOOOWWWW((((1111))))
  269.  
  270.  
  271.  
  272. RRRRAAAAWWWW DDDDAAAATTTTAAAA FFFFOOOORRRRMMMMAAAATTTT
  273.      A cflow raw reference record (the format may change from release to
  274.      release) is a line of white-space separated fields.  Each record
  275.      documents a single cflow instance and is terminated with a new-line.  All
  276.      data is in plain text.  All numbers are in decimal.
  277.  
  278.      ddddaaaattttaaaa----rrrreeeeccccoooorrrrdddd----aaaaddddddddrrrreeeessssssss
  279.           is the integer internal address of a compiler structure as a decimal
  280.           number.  Not used by cflow.
  281.  
  282.      iiiiddddeeeennnnttttiiiiffffiiiieeeerrrr
  283.           is the name of a variable or function or is "{" if this is the
  284.           beginning of a compilation unit, or is "}" if this is the end of a
  285.           compilation unit.
  286.  
  287.      ccccooooddddeeee is one of D,M,A, or R.  D if this is a declaration.  M if this is a
  288.           modification of the variable.  A if the address is taken.  R if this
  289.           is a reference to the variable or function.  If this is the
  290.           beginning or end of a compilation unit, the code is D.
  291.  
  292.      ffffiiiilllleeeennnnaaaammmmeeee
  293.           is the source file name where found.
  294.  
  295.      lllliiiinnnneeee----nnnnuuuummmmbbbbeeeerrrr
  296.           is the line number where the reference was found.  If this is the
  297.           beginning or end of a compilation unit, line-number is 0.
  298.  
  299.      ccccoooolllluuuummmmnnnn----nnnnuuuummmmbbbbeeeerrrr
  300.           is the column number where the reference was found.  If this is the
  301.           beginning or end of a compilation unit, column-number is 0.
  302.  
  303.      ttttyyyyppppeeee is one of B, F, or N.  B means this is a function body (so _c_o_d_e
  304.           above is D).  F means this is a function, not a data variable, and
  305.           not a function body (_c_o_d_e may be D, as a declaration, or A, or R).
  306.           N means this is not a function.  If this is the beginning or end of
  307.           a compilation unit, the type is is N.
  308.  
  309.      ssssccccooooppppeeee----lllleeeevvvveeeellll
  310.           is an integer giving the current local scope level.  Local (inner)
  311.           scopes with no declarations are not interesting so they are not
  312.           counted.  If this is the beginning or end of a compilation unit, the
  313.           scope is 0.
  314.  
  315.      iiiinnnncccclllluuuuddddeeee----ddddeeeepppptttthhhh
  316.           is an integer giving the current #include nesting depth.  If this is
  317.           the beginning or end of a compilation unit, the depth is 0.
  318.  
  319.      ddddaaaattttaaaa----ttttyyyyppppeeee
  320.           is the data type represented as a C declaration with whitespace in
  321.           the declaration replaced by '~' (tilde) characters.  If this is the
  322.           beginning or end of a compilation unit, data-type is "?" or, if
  323.           available, the full path name of the compilation unit.
  324.  
  325.  
  326.  
  327. Page 5                           Release 6.4
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. CCCCFFFFLLLLOOOOWWWW((((1111))))                       SSSSiiiilllliiiiccccoooonnnn GGGGrrrraaaapppphhhhiiiiccccssss                       CCCCFFFFLLLLOOOOWWWW((((1111))))
  335.  
  336.  
  337.  
  338.      ssssttttaaaattttiiiicccc----ffffllllaaaagggg
  339.           is S if the item is a static function or variable or N if it is not.
  340.           If this is the beginning or end of a compilation unit, the static-
  341.           flag is N.
  342.  
  343.      ddddeeeeccccllll----ffffllllaaaagggg
  344.           is C if this is a deClaration, F if this is a deFinition, or N if
  345.           this is neither.  If this is the beginning or end of a compilation
  346.           unit, the decl-flag is N.
  347.  
  348. FFFFIIIILLLLEEEESSSS
  349.      /usr/bin/cflow
  350.      /usr/lib/ecfe
  351.  
  352. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  353.      cc(1), lex(1), yacc(1), pr(1).
  354. OOOOPPPPTTTTIIIIOOOONNNN NNNNOOOOTTTTEEEESSSS
  355.      The ----aaaaccccpppppppp option is ignored.
  356.  
  357.      The ----nnnnooooccccpppppppp option is ignored.  However, _c_f_l_o_w accepts files suffixed with
  358.      ._i as C files.  Also the ----nnnnoooossssttttddddiiiinnnncccc option does not work.
  359.  
  360.      _c_f_l_o_w attempts to understand many of the options normally passed to
  361.      _c_c(1).  Many options are irrelevant to _c_f_l_o_w so they are silently
  362.      ignored.  Others must simply be avoided on the _c_f_l_o_w command line.
  363.  
  364.      Since  the compiler predefines know and created by _c_c are not identical
  365.      to those built into _c_f_l_o_w, it is wise to use ----sssshhhhoooowwww option to _c_c  to
  366.      create a script file with the -D and -U options shown as being passed to
  367.      the compiler.  Invoke _c_f_l_o_w via the script (there are too many -D items
  368.      to do this command creation reliably on the command line).  Edit the
  369.      script to remove options that _c_f_l_o_w does not understand.
  370.  
  371.      Some #pragmas known to the regular _c_c command are not known to _c_f_l_o_w, so
  372.      useless warnings about unknown pragmas may appear at times.
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390. Page 6                           Release 6.4
  391.  
  392.  
  393.  
  394.